package com.tanhua.Intercepter;

import com.tanhua.model.domain.User;

/**
 * ThreadLocal工具类
 */
public class UserHolder {
    private static ThreadLocal<User> userThreadLocal = new ThreadLocal<>();

    /**
     * 存储user
     *
     * @param user
     */
    public static void setUserThreadLocal(User user) {
        userThreadLocal.set(user);
    }

    /**
     * 获取user对象
     * @return
     */
    public static User getUser() {
        return userThreadLocal.get();
    }

    /**
     * 获取电话号码
     * @return
     */
    public static String getMobile(){
        return userThreadLocal.get().getMobile();
    }

    /**
     * 获取userId
     * @return
     */
    public static Long getId(){
        return userThreadLocal.get().getId();
    }
}
